import { Obj } from '@/types/common'
import { Component } from 'vue'

export const useTableAttr = () => {
  // 自动化规则,通过type属性,自动读取目录组件
  const modules: Obj = {}
  const files: Component = import.meta.glob(
    '@/components/control/**/index.vue',
    {
      eager: true,
    },
  )
  Object.keys(files).forEach((item) => {
    const key = item.split('/')
    const name = key[key.length - 2]
    // 组装组件
    modules[`com-${name}`] = files[item].default
  })

  const headerCellStyle = {
    backgroundColor: '#F0F3F7',
    color: '#333',
    fontSize: '14px',
  }
  return {
    headerCellStyle,
    modules,
  }
}
